package com.pes.arcww.form;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

@Entity
@Table(name = "EXAMS")
public class Exams {

	@Id
	@Column(name = "EXA_ID")
	@GeneratedValue
	private Integer exa_id;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "EXA_SUBMITTEDDATE")
	private Date submittedDate;

	@Column(name = "EXA_SCORE")
	private Integer score;

	@Column(name = "EXA_APPROVED")
	private Boolean approved;

	@Column(name = "EXA_QUESTIONSIZE")
	private Integer questionSize;

	@Column(name = "EXA_STARTED")
	private Boolean started;

	@Column(name = "EXA_PENDING")
	private Boolean pending;

	@Column(name = "EXA_FINISHED")
	private Boolean finished;
	
	@ManyToOne
	@JoinColumn(name = "PRO_ID_FK")
	private Profiles profile;
	
	@ManyToOne
	@JoinColumn(name = "USU_EMAIL_FK")
	private Users user;
	
	@OneToMany(mappedBy = "exam", cascade = CascadeType.REMOVE)
	@LazyCollection(LazyCollectionOption.FALSE)
	private Collection<ExamsItems> examItemsList = new ArrayList<ExamsItems>();
	
	public Exams() {
		super();
		this.score = 0;
		this.started = false;
		this.pending = true;
		this.finished = false;
	}

	public Integer getId() {
		return exa_id;
	}

	public void setId(Integer exa_id) {
		this.exa_id = exa_id;
	}

	public Date getSubmittedDate() {
		return submittedDate;
	}

	public void setSubmittedDate(Date submittedDate) {
		this.submittedDate = submittedDate;
	}

	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}

	public Boolean getApproved() {
		return approved;
	}

	public void setApproved(Boolean approved) {
		this.approved = approved;
	}

	public Boolean getStarted() {
		return started;
	}

	public void setStarted(Boolean started) {
		this.started = started;
	}

	public Boolean getPending() {
		return pending;
	}

	public void setPending(Boolean pending) {
		this.pending = pending;
	}

	public Boolean getFinished() {
		return finished;
	}

	public void setFinished(Boolean finished) {
		this.finished = finished;
	}

	public Integer getQuestionSize() {
		return questionSize;
	}

	public void setQuestionSize(Integer questionSize) {
		this.questionSize = questionSize;
	}

	public Profiles getProfile() {
		return profile;
	}

	public void setProfile(Profiles profile) {
		this.profile = profile;
	}

	public Users getUser() {
		return user;
	}

	public void setUser(Users user) {
		this.user = user;
	}

	public Collection<ExamsItems> getExamItemsList() {
		return examItemsList;
	}

	public void setExamItemsList(Collection<ExamsItems> examItemsList) {
		this.examItemsList = examItemsList;
	}
	
	public void addItem(ExamsItems item){
		this.examItemsList.add(item);
	}

}
